package com.hxkj.controller;

import com.hxkj.service.ImgSiteService;
import com.integral.mall.file.service.SysFileService;
import com.platform.common.domain.result.ResultDataStruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.Callable;

/**
 * 站点控制层
 * <p>
 * Created by chenwei on 2018/5/15.
 */
@RestController
@RequestMapping("/img")
public class ImgController {

    private static final Logger LOGGER = LoggerFactory.getLogger(ImgController.class);

    @Autowired
    private ImgSiteService imgSiteService;

    @Value("${cms.realPath}")
    private  String Path;

    @Resource
    private SysFileService sysFileService;



    /**
     * 批量图片上传
     *
     * @param file 图片信息
     * @throws Exception
     */
    @RequestMapping(method = RequestMethod.POST, value = "upload",consumes  ="application/json;charset=UTF-8")
    public Callable<ResultDataStruct<List<String>>> uploadImg(@RequestPart(value = "file") MultipartFile[] file) throws Exception {
        return () -> imgSiteService.imgUpload(file);
    }

}
